package com.sdx.console.content.service;

import java.util.List;

import org.beetl.sql.core.engine.PageQuery;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ibeetl.admin.core.util.PlatformException;

import com.sdx.console.content.dao.ResTagDao;
import com.sdx.console.content.entity.ResTag;
import com.ibeetl.admin.core.service.BaseService;

import javax.annotation.Resource;

/**
 * 标签管理 Service
 */

@Service
@Transactional
public class ResTagService extends BaseService<ResTag>{

    @Resource
	private ResTagDao resTagDao;

    public PageQuery<ResTag>queryByCondition(PageQuery query){
        PageQuery ret =  resTagDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelResTag(List<String> ids){
        try {
            resTagDao.batchDelResTagByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除标签管理失败", e);
        }
    }

	/**
	 * 查询可用的标签列表
	 * @return
	 */
	public List<ResTag> getValidList() {
		ResTag param = new ResTag();
		param.setTagStatus(1);
		List<ResTag> list = resTagDao.template(param);
		return list;
    }
}